import { SvgComponent } from "@/components/base/Svg"
import styled from "@emotion/styled"
import { CSSProperties } from "react"

const Container = styled.div`
    font-family: Gilroy;
    display: flex;
    align-items: center;
    position: relative;
    height: 36rem;
    border-radius: 8rem;
    border: 1rem solid #d5d5d8;
    padding: 0 12rem;
    min-width: 172rem;
    flex: 1;
    background-color: #fff;
`

const Text = styled.span<{ color: CSSProperties["color"] }>`
    font-weight: 500;
    font-size: 14rem;
    height: 20rem;
    line-height: 20rem;
    color: ${({ color }) => color};
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
`

const Arrow = styled.span<{ active: boolean }>`
    width: 20rem;
    height: 20rem;
    position: absolute;
    top: 50%;
    right: 12rem;
    transition: transform 0.2s ease-in-out;
    transform: translateY(-50%) rotate(${({ active }) => (active ? `180deg` : `0deg`)});
`

const IconArrowDownSvg = styled(SvgComponent("pages/HomePage/icon_arrow_down.svg"))``

export function CategoryGameBaseSelect({
    label = "",
    val = "",
    active = false,
    onClick,
}: {
    label: string
    val: string
    active?: boolean
    onClick?: () => void
}) {
    return (
        <Container onClick={() => onClick?.()}>
            <Text color="#69728C">{label}&nbsp;</Text>
            <Text color="#131416">{val}</Text>
            <Arrow active={active}>
                <IconArrowDownSvg />
            </Arrow>
        </Container>
    )
}
